<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        li {
            background: pink;
        }

        div {
            display: none;
        }
    </style>
</head>

<body>
    <ul>
        <li>
            <h2>视频</h2>
            <div>
                <p>1</p>
                <p>2</p>
                <p>3</p>
            </div>
        </li>
    </ul>

    <script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
    <script>
        let ul = document.querySelector('ul');
        let str = ``;
        $.ajax({
            url: 'http://suggestion.baidu.com/su',
            data: {
                wd: `2`
            },
            jsonp: 'cb',
            dataType: 'jsonp',
            success(res) {
                console.log(res.s);
                res.s.forEach(item => {
                    str += `    <li>
                                <h2>${item}</h2>
                                <div>
                                <p>${item}</p>
                                <p>${item}</p>
                                <p>${item}</p>
                                </div>
                                </li>`
                });
                ul.innerHTML = str;

                let btn = document.getElementsByTagName('h2');
                let div = document.getElementsByTagName('div');


                for (let i = 0; i < btn.length; i++) {
                    btn[i].tag = true;
                    btn[i].onclick = function () {
                        if (this.tag == true) {
                            div[i].style.display = 'block';
                            this.tag = false;
                        } else {
                            div[i].style.display = 'none';
                            this.tag = true;
                        }
                    }
                }
            }
        })


    </script>
</body>

</html>